home *** CD-ROM | disk | FTP | other *** search
/ Graphics Plus / Graphics Plus.iso / libs / sphigs / sph_srgp.lha / srgp / src / srgp_state_MAC.c < prev    next >
Encoding:
C/C++ Source or Header  |  1992-01-09  |  2.8 KB  |  144 lines

  1. #include "HEADERS.h"
  2. #include "srgplocal.h"
  3. #include "ChooseWhichQuickDraw.h"
  4.  
  5. /** Mac VERSION OF state.c
  6. This contains no conditionally compiled code because it should be used
  7. only in the Mac version.
  8. **/
  9.  
  10. void ReportSpecialError (char *message, boolean is_fatal)
  11. {
  12.    GrafPtr saveport = thePort;
  13.    WindowPtr tempwin;
  14.    
  15.    Rect window_bounds = {50, 50,   200,300};
  16.    Rect te_bounds = {5,5, 145,245};
  17.    SetPort (tempwin = NewWindow (0L, &window_bounds, 
  18.                (is_fatal ? "\pFatal Error" : "\pWarning"), true, 
  19.                        rDocProc, -1L, false, 0));
  20.    
  21.    TextBox (message, (long)(strlen(message)), &te_bounds, teJustLeft);
  22.    SRGP_beep();
  23.    sleep (5);
  24.    if (is_fatal)
  25.       ExitToShell();
  26.    else {
  27.       DisposeWindow (tempwin);
  28.       SetPort (saveport);
  29.    }
  30. }
  31.  
  32. static void InitMacintosh (void)
  33. {
  34.    MaxApplZone();
  35.     
  36.    InitGraf(&thePort);
  37.    InitFonts();
  38.    FlushEvents(everyEvent, 0);
  39.    InitWindows();
  40.    InitMenus();
  41.    TEInit();
  42.    InitDialogs(0L);
  43.    InitCursor();
  44.  
  45.     
  46. }
  47.  
  48. char res_message[] = "Resource file not found!  Read the MacSRGP_README file!";
  49.  
  50.  
  51.  
  52. void SRGP__initGraphicsDevice (char *name, int requested_planes, boolean debugasap)
  53. {
  54.    Rect windowBounds;
  55.    char resource_proclaimer[256];
  56.    
  57.    InitMacintosh();
  58.    
  59.    GetIndString (resource_proclaimer, 12345, 1);
  60.    PtoCstr(resource_proclaimer);
  61.    if (0 != strcmp("SRGP resources",resource_proclaimer))
  62.       ReportSpecialError (res_message, FATAL);
  63.    
  64.    SetRect (&windowBounds, 0, 40, 
  65.                  srgp__curActiveCanvasSpec.max_xcoord+1,
  66.                  40+srgp__curActiveCanvasSpec.max_ycoord+1);
  67.    CtoPstr(name);
  68.    
  69. #ifdef COLOR_QUICKDRAW
  70.    srgpmac__cwindow = 
  71.       NewCWindow (0L, &windowBounds, name, true, noGrowDocProc, -1L, true, 0);
  72. #else
  73.    srgpmac__cwindow = 
  74.       NewWindow (0L, &windowBounds, name, true, noGrowDocProc, -1L, true, 0);
  75. #endif
  76.    srgp__curActiveCanvasSpec.drawable.win = srgpmac__cwindow;   
  77.    SetPort(srgpmac__cwindow);
  78.    PtoCstr(name);
  79.   
  80.    SRGP__initColor (requested_planes);
  81.  
  82.    /* INIT TIME STAMP */
  83.    srgpx__starttime = srgpx__cur_time = TickCount();
  84.  
  85.    /* SET GRAPHICS CONTEXT */
  86.  
  87.    /* INIT INPUT */
  88.  
  89.    /* SET 0th CANVAS-WINDOW PROPERTIES */
  90.  
  91.    /* We set up for backing store. */
  92.  
  93.    /* Load the sole menu in the menu bar. */    
  94.    ClearMenuBar();
  95.    InsertMenu (srgpmac__srgpmenu=GetMenu(200), 0);
  96.    DisableItem (srgpmac__srgpmenu, 1);
  97.    DrawMenuBar();
  98. }
  99.  
  100.  
  101.  
  102. void SRGP__cleanupMacMemory()
  103. {
  104.    SRGP__cleanupColor();
  105.    /* later must clean up canvases */
  106. }
  107.  
  108.  
  109. /** SRGP_refresh
  110. **/
  111.  
  112. void
  113. SRGP_refresh ()
  114. {
  115. /* only needed on X11 workstations */
  116. }
  117.  
  118.  
  119.  
  120. /** SRGP_enableSynchronous
  121. No-op for Mac version.
  122. **/
  123.  
  124. void
  125. SRGP_enableSynchronous ()
  126. {
  127. }
  128.  
  129.  
  130.  
  131. /*!*/
  132. void
  133. SRGP_allowResize (boolean allow)
  134. {
  135.    EnableItem (srgpmac__srgpmenu,1);
  136. }
  137.  
  138.  
  139. void
  140. SRGP__forceScreenResize (int newwidth, int newheight)
  141. {
  142.    SizeWindow (srgpmac__cwindow, newwidth, newheight, FALSE);
  143. }
  144.